package 机试题16年;

import java.util.Scanner;

/**
 * Created by hest0 on 2017/4/18.
 */
public class 聊天 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int p = sc.nextInt();
            int q = sc.nextInt();
            int l = sc.nextInt();
            int r = sc.nextInt();

            int[][] a = new int[p][2];
            int[][] b = new int[q][2];

            for (int i = 0; i < p; i++) {
                a[i][0] = sc.nextInt();
                a[i][1] = sc.nextInt();
            }

            for (int i = 0; i < q; i++) {
                b[i][0] = sc.nextInt();
                b[i][1] = sc.nextInt();
            }

            System.out.println(talk(p, q, l, r, a, b));
        }
        sc.close();
    }

    private static int talk(int p, int q, int l, int r, int[][] a, int[][] b) {
        int count = 0;
        for (int i = l; i <= r; i++) {
            if (isPorperTime(a, b, i))
                count++;
        }
        return count;
    }

    private static boolean isPorperTime(int[][] a, int[][] b, int t) {
        for (int i = 0; i < a.length; i++) {
            int a1 = a[i][0];
            int a2 = a[i][1];
            for (int j = 0; j < b.length; j++) {
                int b1 = b[j][0] + t;
                int b2 = b[j][1] + t;
                if (a2 >= b1 && a1 <= b2)
                    return true;
            }
        }
        return false;
    }

}
